﻿using Microsoft.Phone.Info;
using System;
using System.Collections.Generic;
using System.Device.Location;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsPhone_Map_TTTN
{
    class MapUDPPackage
    {
        public MapUDPPackage(GeoCoordinate gps)
        {
            this.latitude = gps.Latitude;
            this.longitude = gps.Longitude ;
            this.elevation = gps.Altitude;
            this.accuracy = (gps.VerticalAccuracy+gps.HorizontalAccuracy)/2;
            this.speed = gps.Speed;
            this.IMEI = ConvertIMEI((byte[])DeviceExtendedProperties.GetValue("DeviceUniqueId"));
            this.currentTime = DateTime.Now;
        }
        public String toString()
        {
            return this.IMEI + separate
                + longitude + separate
                + latitude + separate
                + elevation + separate
                + currentTime.ToString("yyMMddhhmmss") + separate
                + accuracy + separate 
                + speed;
        }

        public String IMEI { set; get; }
        public Double longitude {set; get;}
        public Double latitude  {set; get;}
        public Double elevation {set; get;}
        public DateTime currentTime {set; get;}
        public Double accuracy  {set; get;}
        public Double speed {set; get;}
        private String separate = " ";
        private String ConvertIMEI(byte[] imei)
        {
            String temp = "";
            for (int i = 0; i < imei.Length; i++)
            {
                temp += imei[i];
            }
            return temp;
        }
     
    }
}
